SET(TEST_PROG_NAME test-sdk-${SOC})

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/extlib/cunit/include)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/extlib/ncurses/include)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/external/ivs/include)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/imp/include)

SET(SRCS
    test_main.cpp
    common/test_log.c
    common/test_module.c
    common/test_system.c
    soc-t15/test_1framesource_2encoder.c
    soc-t15/test_emulator.c
#    soc-t15/test_ivs.c
    soc-t15/test_adc.c
    soc-t15/test_encoder.c
    soc-t15/test_pwm.c
    soc-t15/test_audio.c
    soc-t15/test_framesource.c
    soc-t15/test_vbm.c
    soc-t15/test_cipher.c
#    soc-t15/test_framesource_ivs.c
)

ADD_EXECUTABLE(${TEST_PROG_NAME}-glibc ${SRCS})
ADD_EXECUTABLE(${TEST_PROG_NAME}-glibc-static ${SRCS})
ADD_EXECUTABLE(${TEST_PROG_NAME}-uclibc ${SRCS})
ADD_EXECUTABLE(${TEST_PROG_NAME}-uclibc-static ${SRCS})

SET_TARGET_PROPERTIES(${TEST_PROG_NAME}-glibc PROPERTIES
    OUTPUT_NAME "${TEST_PROG_NAME}"
    RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/glibc
)

SET_TARGET_PROPERTIES(${TEST_PROG_NAME}-glibc-static PROPERTIES
    OUTPUT_NAME "${TEST_PROG_NAME}-static"
    RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/glibc
)

SET_TARGET_PROPERTIES(${TEST_PROG_NAME}-uclibc PROPERTIES
    OUTPUT_NAME "${TEST_PROG_NAME}"
    RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/uclibc
    LINK_FLAGS "-muclibc"
    COMPILE_FLAGS "-muclibc"
)

SET_TARGET_PROPERTIES(${TEST_PROG_NAME}-uclibc-static PROPERTIES
    OUTPUT_NAME "${TEST_PROG_NAME}-static"
    RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/uclibc
    LINK_FLAGS "-muclibc"
    COMPILE_FLAGS "-muclibc"
)

ADD_DEPENDENCIES(${TEST_PROG_NAME}-glibc imp_shared_glibc sysutils_shared_glibc alog_shared_glibc)
ADD_DEPENDENCIES(${TEST_PROG_NAME}-glibc-static imp_static_glibc sysutils_static_glibc alog_static_glibc)
ADD_DEPENDENCIES(${TEST_PROG_NAME}-uclibc imp_shared_uclibc sysutils_shared_uclibc alog_shared_uclibc)
ADD_DEPENDENCIES(${TEST_PROG_NAME}-uclibc-static imp_static_uclibc sysutils_static_uclibc alog_static_uclibc)

#INSTALL(TARGETS ${TEST_PROG_NAME}-glibc RUNTIME DESTINATION ${BIN_INSTALL_DIR_GLIBC})
#INSTALL(TARGETS ${TEST_PROG_NAME}-glibc-static RUNTIME DESTINATION ${BIN_INSTALL_DIR_GLIBC})
#INSTALL(TARGETS ${TEST_PROG_NAME}-uclibc RUNTIME DESTINATION ${BIN_INSTALL_DIR_UCLIBC})
#INSTALL(TARGETS ${TEST_PROG_NAME}-uclibc-static RUNTIME DESTINATION ${BIN_INSTALL_DIR_UCLIBC})

TARGET_LINK_LIBRARIES(${TEST_PROG_NAME}-glibc
    ${PROJECT_BINARY_DIR}/lib-glibc/libimp.so
    ${PROJECT_BINARY_DIR}/lib-glibc/libsysutils.so
    ${PROJECT_BINARY_DIR}/lib-glibc/libalog.so
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/glibc/libmxu_objdetect.so
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/glibc/libmxu_contrib.so
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/glibc/libmxu_merge.so
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/glibc/libmxu_video.so
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/glibc/libmxu_imgproc.so
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/glibc/libmxu_core.so
    ${CMAKE_CURRENT_SOURCE_DIR}/extlib/cunit/lib-glibc/libcunit.a
    ${CMAKE_CURRENT_SOURCE_DIR}/extlib/ncurses/lib-glibc/libncurses.a
    pthread rt m
)

TARGET_LINK_LIBRARIES(${TEST_PROG_NAME}-glibc-static
    ${PROJECT_BINARY_DIR}/lib-glibc/libimp.a
    ${PROJECT_BINARY_DIR}/lib-glibc/libsysutils.a
    ${PROJECT_BINARY_DIR}/lib-glibc/libalog.a
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/glibc/libmxu_objdetect.a
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/glibc/libmxu_contrib.a
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/glibc/libmxu_merge.a
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/glibc/libmxu_video.a
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/glibc/libmxu_imgproc.a
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/glibc/libmxu_core.a
    ${CMAKE_CURRENT_SOURCE_DIR}/extlib/cunit/lib-glibc/libcunit.a
    ${CMAKE_CURRENT_SOURCE_DIR}/extlib/ncurses/lib-glibc/libncurses.a
    pthread rt m
)

TARGET_LINK_LIBRARIES(${TEST_PROG_NAME}-uclibc
    ${PROJECT_BINARY_DIR}/lib-uclibc/libimp.so
    ${PROJECT_BINARY_DIR}/lib-uclibc/libsysutils.so
    ${PROJECT_BINARY_DIR}/lib-uclibc/libalog.so
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/uclibc/libmxu_objdetect.so
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/uclibc/libmxu_contrib.so
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/uclibc/libmxu_merge.so
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/uclibc/libmxu_video.so
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/uclibc/libmxu_imgproc.so
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/uclibc/libmxu_core.so
    ${CMAKE_CURRENT_SOURCE_DIR}/extlib/cunit/lib-uclibc/libcunit.a
    ${CMAKE_CURRENT_SOURCE_DIR}/extlib/ncurses/lib-uclibc/libncurses.a
    pthread rt m
)

TARGET_LINK_LIBRARIES(${TEST_PROG_NAME}-uclibc-static
    ${PROJECT_BINARY_DIR}/lib-uclibc/libimp.a
    ${PROJECT_BINARY_DIR}/lib-uclibc/libsysutils.a
    ${PROJECT_BINARY_DIR}/lib-uclibc/libalog.a
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/uclibc/libmxu_objdetect.a
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/uclibc/libmxu_contrib.a
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/uclibc/libmxu_merge.a
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/uclibc/libmxu_video.a
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/uclibc/libmxu_imgproc.a
#    ${PROJECT_SOURCE_DIR}/external/mxu/lib/uclibc/libmxu_core.a
    ${CMAKE_CURRENT_SOURCE_DIR}/extlib/cunit/lib-uclibc/libcunit.a
    ${CMAKE_CURRENT_SOURCE_DIR}/extlib/ncurses/lib-uclibc/libncurses.a
    pthread rt m
)
